﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_BidTableProductSave : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckProjectComp);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (Request.Form["txtProductId"] != null)
            {
                int intProjectId = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["ProjectId"]));
                string[] strProductId = Request.Form["txtProductId"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                if (strProductId.Length > 0)
                {
                    string strSql;
                    Db db = new Db();

                    foreach (string strId in strProductId)
                    {
                        try
                        {
                            strSql = SysFun.ToInt(strId) + "," + intProjectId;
                            strSql = "Insert Into bid_project_product (bidtableid,ProductId,ProjectId) Values (18822," + strSql + ")";
                            db.Command(strSql);
                            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                            HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "添加", "bid_project_product", strSql, "../Agency/BidTableProductSave.aspx");

                        }
                        catch { }
                    }

                    db.Close();

                    Response.Write("<Script Language=vbscript>\r\n");
                    Response.Write("msgbox \"保存成功。\"\r\n");
                    Response.Write("window.parent.opener.location.reload()\r\n");
                    Response.Write("window.parent.close()\r\n");
                    Response.Write("</Script>\r\n");
                }
                else
                {
                    Response.Write("");
                }

            }
        }
    }
}
